#include <cstdlib>
#include <cstdio>

#include "Tree.h"

#define MAXSIZE 100



typedef struct Stack{
	TreeNode data[MAXSIZE];
	int top;
} Stack;

void initStack(Stack &stack) {
	stack.top = -1;
}

bool idEmpty(Stack &stack) {
	return stack.top > -1;
}

/**
 * 栈内添加元素
 * @param stack 栈
 * @param treeNode 元素
 * @return
 */
bool push(Stack &stack, TreeNode treeNode) {
	if (stack.top == MAXSIZE - 1) {
		return false;
	}
	stack.data[++stack.top] = treeNode;
	return true;
}

/**
 * 栈弹出元素
 * @param stack 栈
 * @param treeNode 元素
 * @return
 */
bool pop(Stack &stack, TreeNode &treeNode) {
	if (stack.top == -1) {
		return false;
	}
	treeNode = stack.data[stack.top--];
	return true;
}